package com.nbsaas.boot.product.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import com.nbsaas.boot.jpa.data.entity.LongEntity;
import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.annotations.Comment;

/**
 * 商品SKU规格值实体
 * 用于关联商品SKU与具体的规格值
 */
@Comment("商品SKU规格值")
@Data
@FormAnnotation(title = "商品SKU规格值管理", model = "商品SKU规格值")
@Entity
@Table(name = "nb_product_sku_spec_value")
public class ProductSkuSpecValue extends LongEntity {


    @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT) )
    @Comment("所属商品SKU")
    @FieldName
    @FieldConvert
    @FormField(title = "商品SKU", type = InputType.select, option = "productSku")
    @ManyToOne(fetch = FetchType.LAZY)
    private ProductSku productSku;


    @Comment("商品id")
    private Long productId;

    @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT) )
    @Comment("关联规格值")
    @FieldName
    @FieldConvert
    @FormField(title = "规格值", type = InputType.select, option = "specValue")
    @ManyToOne(fetch = FetchType.LAZY)
    private SpecValue specValue;

    @Comment("显示顺序")
    @FormField(title = "排序号", grid = true, type = InputType.el_input_number)
    private Integer sortNum;

}
